package com.likai.controller;

import com.likai.entry.WeatherResponse;
import com.likai.service.WeatherDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/weather")
public class WeatherController {

    @Autowired
    private WeatherDataService weatherDataService;


    @RequestMapping(value = "/cityId/{cityId}",method = {RequestMethod.GET})
    public WeatherResponse cityId(@PathVariable("cityId") String cityId) {
        return weatherDataService.getDataByCityId(cityId);
    }

    @RequestMapping(value = "/cityName/{cityName}",method = {RequestMethod.GET})
    public WeatherResponse cityName(@PathVariable("cityName") String cityName) {
        return weatherDataService.getDataByCityName(cityName);
    }
}
